package com.yd.controller.yd;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.util.Iterator;
import java.util.Properties;

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;


public class YD_ShanghuJiage {
	//通过商户id和省获取商户价格信息
	public static JSONObject getJiageByshids(String merchantid,String address) throws MalformedURLException, IOException{
		
		String urlruls=getUrlValue("urlruls.shjg")+"&merchantid="+merchantid+"&address="+address;
		Connection connect = Jsoup.connect(urlruls);
		// 带参数开始
		connect.data("merchantid", "merchantid");
		connect.data("address", "address");
		// 带参数结束
		Document document = connect.post();
		String str=document.select("body").text().trim();
		JSONObject jso=JSON.parseObject(str);
		return jso;
		
	}

	private static String getUrlValue(String urlName) {
		  String url = null;
	        Properties prop = new Properties();
	        try {
	            ClassLoader classLoader = YD_Users.class.getClassLoader();// 读取属性文件xxxxx.properties
	            InputStream in = classLoader.getResourceAsStream("url_shanghujiage.properties");
	            prop.load(in); /// 加载属性列表
	            Iterator<String> it = prop.stringPropertyNames().iterator();
	            while (it.hasNext()) {
	                if (it.next().equals(urlName)) {
	                    url = prop.getProperty(urlName);
	                }
	            }
	            in.close();
	        } catch (Exception e) {
	            
	        }
	        return url;
	}
	public static void main(String[] args) {
		System.out.println(getUrlValue("urlruls.shjg"));
	
	}
	
	
	
	
	
}

















